﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SG.Lang.Dry.Controlling;
using SG.Lang.Dry.Mirrors;

namespace SG.Lang.Dry.Code
{
    public class If : Expression
    {
        private readonly Expression _condition;

        private readonly Expression _then;

        private readonly Expression _else;

        protected If(ref ElementRecord elementRecord, ref ExpressionRecord expressionRecord)
            : base(ref elementRecord, ref expressionRecord)
        {
            _condition = expressionRecord.Value.ResolveExpression();

            _then = expressionRecord.Left.ResolveExpression();

            _else = expressionRecord.Right.ResolveExpression();
        }

        public Expression Condition { get { return _condition; } }

        public Expression Then { get { return _then; } }

        public Expression Else { get { return _else; } }
    }
}
